package org.wang.service.impl;

import com.baomidou.mybatisplus.plugins.Page;
import org.wang.domain.TenantType;
import org.wang.mapper.TenantTypeMapper;
import org.wang.query.TenantTypeQuery;
import org.wang.service.ITenantTypeService;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import org.wang.util.PageList;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 租户(机构)类型表 服务实现类
 * </p>
 *
 * @author Zebord
 * @since 2020-02-14
 */
@Service
public class TenantTypeServiceImpl extends ServiceImpl<TenantTypeMapper, TenantType> implements ITenantTypeService {

    @Autowired
    private TenantTypeMapper tenantTypeMapper;


    @Override
    public PageList<TenantType> selectPageLiset(TenantTypeQuery query) {
        //作为分页条件传入
        Page<TenantType> page = new Page<>(query.getPage(), query.getRows());

        //查询得到当前页数据
        List<TenantType> tenantTypes = tenantTypeMapper.loadPageLiset(page, query);

        //分页条件中返回了总数
        //把总数+当前页数据
        return new PageList<TenantType>(page.getTotal(),tenantTypes);
    }
}
